package com.cskaoyan.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * 响应ModelAndView
 * @author stone
 * @date 2022/06/21 14:23
 */
@Controller
public class ModelAndViewController {

    @RequestMapping("hello")
    public ModelAndView hello() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/hello.jsp");
        modelAndView.addObject("username", "松哥");
        modelAndView.addObject("email", "songge@cskaoyan.com");
        return modelAndView;
    }

    // method.invoke(instance,args)
    @RequestMapping("hello2")
    public String hello2(Model model) {
        model.addAttribute("username", "李艮隶");
        model.addAttribute("email", "ligenli@cskaoyan.com");
        return "/hello.jsp";
    }
}
